﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Drawing.Imaging;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using Models;
using Common;
using OCR;

namespace ImageProcessor
{
    public class ImageManager
    {
        private ImageWorker imageWorker = null;
        private OCRReader OCRReader = null;

        public ImageManager()
        {
            imageWorker = new ImageWorker();
            OCRReader = new OCRReader();
        }

        public PokerTable GetPokerTableFromImage(string directoryPath)
        {
            PokerTable result = new PokerTable();

            result.IsMyTurn = IsMyTurn(directoryPath);
            //just for testing
            //result.IsMyTurn = true;
            if (result.IsMyTurn)
            {
                CropImageForPieces(directoryPath);
                GetDataFromPieces(result, directoryPath);
            }

            return result;
        }

        private bool IsMyTurn(string directoryPath)
        {
            bool result = false;
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                Bitmap mainWindowsBitmap = new Bitmap(mainWindow);
                Color pixel = mainWindowsBitmap.GetPixel(425, 500);
                //if fold button's background is red then we will come
                if (pixel.R > 150 && pixel.G < 50 && pixel.B < 50)
                {
                    result = true;
                }
            }

            return result;
        }

        private void GetDataFromPieces(PokerTable result, string directoryPath)
        {
            GetDataFromButtons(result, directoryPath);
            GetDataFromPot(result, directoryPath);
            GetDataFromHoleCards(result, directoryPath);
            GetTableState(result, directoryPath);
            GetOpponentsCount(result, directoryPath);
            GetDataFromBoardCards(result, directoryPath);
        }

        private void GetDataFromBoardCards(PokerTable result, string directoryPath)
        {
            if (result.TableState == TableState.PostFlop || result.TableState == TableState.Turn || result.TableState == TableState.River)
            {
                GetDataFromFlopCards(result, directoryPath);
            }

            if (result.TableState == TableState.Turn || result.TableState == TableState.River)
            {
                GetDataFromTurnCard(result, directoryPath);
            }

            if (result.TableState == TableState.River)
            {
                GetDataFromRiver(result, directoryPath);
            }
        }

        private void GetDataFromRiver(PokerTable result, string directoryPath)
        {
            //fifth
            string fifthBoardCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.FifthBoardCardRank));
            fifthBoardCardRank = PartyPokerTranlator.CardRankTranslator(fifthBoardCardRank);
            result.BoardCards.RiverCard.Rank = fifthBoardCardRank;

            using (Image firstSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.FifthBoardCardSuit)))
            {
                Bitmap firstSuitBmp = new Bitmap(firstSuitImg);
                string suitForCard = GetSuitForCard(firstSuitBmp);
                result.BoardCards.RiverCard.Suit = suitForCard;
            }
        }

        private void GetDataFromTurnCard(PokerTable result, string directoryPath)
        {
            //fourth
            string fourthBoardCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.FourthBoardCardRank));
            fourthBoardCardRank = PartyPokerTranlator.CardRankTranslator(fourthBoardCardRank);
            result.BoardCards.TurnCard.Rank = fourthBoardCardRank;

            using (Image firstSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.FourthBoardCardSuit)))
            {
                Bitmap firstSuitBmp = new Bitmap(firstSuitImg);
                string suitForCard = GetSuitForCard(firstSuitBmp);
                result.BoardCards.TurnCard.Suit = suitForCard;
            }
        }

        private void GetDataFromFlopCards(PokerTable result, string directoryPath)
        {
            //first
            string firstBoardCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.FirstBoardCardRank));
            firstBoardCardRank = PartyPokerTranlator.CardRankTranslator(firstBoardCardRank);
            result.BoardCards.FlopCards.FirstFlopCard.Rank = firstBoardCardRank;

            using (Image firstSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.FirstBoardCardSuit)))
            {
                Bitmap firstSuitBmp = new Bitmap(firstSuitImg);
                string suitForFirstCard = GetSuitForCard(firstSuitBmp);
                result.BoardCards.FlopCards.FirstFlopCard.Suit = suitForFirstCard;
            }
            //second
            string secondBoardCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.SecondBoardCardRank));
            secondBoardCardRank = PartyPokerTranlator.CardRankTranslator(secondBoardCardRank);
            result.BoardCards.FlopCards.SecondFlopCard.Rank = secondBoardCardRank;

            using (Image firstSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.SecondBoardCardSuit)))
            {
                Bitmap firstSuitBmp = new Bitmap(firstSuitImg);
                string suitForCard = GetSuitForCard(firstSuitBmp);
                result.BoardCards.FlopCards.SecondFlopCard.Suit = suitForCard;
            }

            //thrid
            string thirdBoardCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.ThirdBoardCardRank));
            thirdBoardCardRank = PartyPokerTranlator.CardRankTranslator(thirdBoardCardRank);
            result.BoardCards.FlopCards.ThirdFlopCard.Rank = thirdBoardCardRank;

            using (Image firstSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.ThirdBoardCardSuit)))
            {
                Bitmap firstSuitBmp = new Bitmap(firstSuitImg);
                string suitForCard = GetSuitForCard(firstSuitBmp);
                result.BoardCards.FlopCards.ThirdFlopCard.Suit = suitForCard;
            }
        }

        private void GetOpponentsCount(PokerTable result, string directoryPath)
        {
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                Bitmap mainWindowBmp = new Bitmap(mainWindow);
                Color opponent_1 = mainWindowBmp.GetPixel(602, 304);
                Color opponent_2 = mainWindowBmp.GetPixel(439, 334);
                Color opponent_3 = mainWindowBmp.GetPixel(266, 335);
                Color opponent_4 = mainWindowBmp.GetPixel(103, 305);
                Color opponent_5 = mainWindowBmp.GetPixel(20, 185);
                Color opponent_6 = mainWindowBmp.GetPixel(102, 117);
                Color opponent_7 = mainWindowBmp.GetPixel(237, 84);
                Color opponent_8 = mainWindowBmp.GetPixel(461, 84);
                Color opponent_9 = mainWindowBmp.GetPixel(598, 79);

                List<Color> opponents = new List<Color>() { opponent_1, opponent_2, opponent_3, opponent_4, opponent_5, opponent_6, opponent_7, opponent_8, opponent_9 };
                result.OpponentsCount = CountActivePlayer(opponents);
            }
        }

        private int CountActivePlayer(List<Color> opponents)
        {
            int count = opponents.Count(x => x.R == 0 && x.G == 0 && x.B == 0);
            count = count + 1;//opponents plus me
            return count;
        }

        private void GetTableState(PokerTable result, string directoryPath)
        {
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                //set as preflop
                result.TableState = TableState.PreFlop;
                Bitmap mainWindowBmp = new Bitmap(mainWindow);
                //flop cards
                Color firstCardBGPixel = mainWindowBmp.GetPixel(247, 189);
                Color secondCardBGPixel = mainWindowBmp.GetPixel(311, 189);
                Color thirdCardBGPixel = mainWindowBmp.GetPixel(374, 189);

                if ((firstCardBGPixel.R == 255) && (firstCardBGPixel.G == 255) && (firstCardBGPixel.B == 255) && (secondCardBGPixel.R == 255) && (secondCardBGPixel.G == 255) && (secondCardBGPixel.B == 255) && (thirdCardBGPixel.R == 255) && (thirdCardBGPixel.G == 255) && (thirdCardBGPixel.B == 255))
                {
                    result.TableState = TableState.PostFlop;
                }

                //turn card
                Color fourthCardBGPixel = mainWindowBmp.GetPixel(438, 189);
                if ((fourthCardBGPixel.R == 255) && (fourthCardBGPixel.G == 255) && (fourthCardBGPixel.B == 255))
                {
                    result.TableState = TableState.Turn;
                }
                //river card
                Color fifthCardBGPixel = mainWindowBmp.GetPixel(502, 189);
                if ((fifthCardBGPixel.R == 255) && (fifthCardBGPixel.G == 255) && (fifthCardBGPixel.B == 255))
                {
                    result.TableState = TableState.River;
                }
            }
        }

        private void GetDataFromHoleCards(PokerTable result, string directoryPath)
        {
            string firstHoleCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.FirstHoleCardRank));
            firstHoleCardRank = PartyPokerTranlator.CardRankTranslator(firstHoleCardRank);
            string secondHoleCardRank = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.SecondHoleCardRank));
            secondHoleCardRank = PartyPokerTranlator.CardRankTranslator(secondHoleCardRank);

            result.HoleCards.FirstHoleCard.Rank = firstHoleCardRank;
            result.HoleCards.SecondHoleCard.Rank = secondHoleCardRank;

            using (Image firstSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.FirstHoleCardSuit)))
            {
                Bitmap firstSuitBmp = new Bitmap(firstSuitImg);
                string suitForFirstCard = GetSuitForCard(firstSuitBmp);
                result.HoleCards.FirstHoleCard.Suit = suitForFirstCard;
            }

            using (Image secondSuitImg = Image.FromFile(Path.Combine(directoryPath, ImageNames.SecondHoleCardSuit)))
            {
                Bitmap secondSuitBmp = new Bitmap(secondSuitImg);
                string suitForSecondCard = GetSuitForCard(secondSuitBmp);
                result.HoleCards.SecondHoleCard.Suit = suitForSecondCard;
            }
        }

        private string GetSuitForCard(Bitmap bmp)
        {
            string result = string.Empty;
            //Diamond
            Color pixel = bmp.GetPixel(9, 5);
            if ((pixel.R > 130) && (pixel.G < 10) && (pixel.B < 30))
            {
                return CardSuits.Diamond;
            }
            //Heart
            pixel = bmp.GetPixel(10, 10);
            if ((pixel.R > 140) && (pixel.G < 10) && (pixel.B < 30))
            {
                return CardSuits.Heart;
            }
            //Spead
            pixel = bmp.GetPixel(13, 8);
            if ((pixel.R < 20) && (pixel.G < 20) && (pixel.B < 20))
            {
                return CardSuits.Spade;
            }
            //Club
            pixel = bmp.GetPixel(8, 11);
            if ((pixel.R < 10) && (pixel.G < 10) && (pixel.B < 10))
            {
                return CardSuits.Club;
            }

            return result;
        }

        private void GetDataFromPot(PokerTable result, string directoryPath)
        {
            decimal pot = 0;

            string potFromOCR = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.Pot));
            decimal.TryParse(potFromOCR, out pot);
            if (pot != 0)
            {
                result.Pot = pot;
            }
            else
            {
                potFromOCR = OCRReader.RecognizeWithMODI(Path.Combine(directoryPath, ImageNames.Pot));
                decimal.TryParse(potFromOCR, out pot);
                result.Pot = pot;
            }
        }

        private void GetDataFromButtons(PokerTable result, string directoryPath)
        {
            //check
            result.TableActionButtons.CheckButtonText = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.CheckButton));
            if (result.TableActionButtons.CheckButtonText.StartsWith(PartyPokerDicitonary.Check))
            {
                result.TableActionButtons.CheckButtonEnabled = true;
            }

            //call
            result.TableActionButtons.CallButtonText = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.CallButton));
            if (result.TableActionButtons.CallButtonText.StartsWith(PartyPokerDicitonary.Call))
            {
                result.TableActionButtons.CallButtonEnabled = true;
            }
            if (result.TableActionButtons.CallButtonEnabled)
            {
                string callButtonChips = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.CallButtonChips));
                callButtonChips = callButtonChips.Replace("(", "").Replace(")", "").Replace("$", "");
                result.TableActionButtons.CallButtonChips = decimal.Parse(callButtonChips);
            }

            //bet
            result.TableActionButtons.BetButtonText = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.BetButton));
            if (result.TableActionButtons.BetButtonText.StartsWith(PartyPokerDicitonary.Bet) || (result.TableActionButtons.BetButtonText.StartsWith(PartyPokerDicitonary.Bet2)) || (result.TableActionButtons.BetButtonText.StartsWith(PartyPokerDicitonary.Bet3)))
            {
                result.TableActionButtons.BetButtonEnabled = true;
            }

            //fold
            result.TableActionButtons.FoldButtonText = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.FoldButton));
            if (result.TableActionButtons.FoldButtonText.StartsWith(PartyPokerDicitonary.Fold) || result.TableActionButtons.FoldButtonText.StartsWith(PartyPokerDicitonary.Fold2))
            {
                result.TableActionButtons.FoldButtonEnabled = true;
            }

            //raise
            result.TableActionButtons.RaiseButtonText = OCRReader.Recognize(Path.Combine(directoryPath, ImageNames.RaiseButton));
            if (result.TableActionButtons.RaiseButtonText.StartsWith(PartyPokerDicitonary.Raise) || result.TableActionButtons.RaiseButtonText.StartsWith(PartyPokerDicitonary.Raise2))
            {
                result.TableActionButtons.RaiseButtonEnabled = true;
            }
        }

        private void CropImageForPieces(string directoryPath)
        {
            CropButtons(directoryPath);
            CropPot(directoryPath);
            CropHoleCards(directoryPath);
            CropBoardCards(directoryPath);
        }

        private void CropBoardCards(string directoryPath)
        {
            //first card
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFirstBoardCardRank(mainWindow, directoryPath);
            }
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFirstBoardCardSuit(mainWindow, directoryPath);
            }

            //second card
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForSecondBoardCardRank(mainWindow, directoryPath);
            }
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForSecondBoardCardSuit(mainWindow, directoryPath);
            }

            //third card
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForThirdBoardCardRank(mainWindow, directoryPath);
            }
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForThirdBoardCardSuit(mainWindow, directoryPath);
            }

            //fourth card
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFourthBoardCardRank(mainWindow, directoryPath);
            }
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFourthBoardCardSuit(mainWindow, directoryPath);
            }

            //fifth card
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFifthBoardCardRank(mainWindow, directoryPath);
            }
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFifthBoardCardSuit(mainWindow, directoryPath);
            }
        }

        private void CropForFifthBoardCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropFifthBoardCard = imageWorker.CropImage(mainWindow, 25, 20, 501, 211);
            string pathBet = Path.Combine(directoryPath, ImageNames.FifthBoardCardSuit);
            imageWorker.SaveImage(cropFifthBoardCard, pathBet);
        }

        private void CropForFourthBoardCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropFourthBoardCard = imageWorker.CropImage(mainWindow, 25, 20, 437, 211);
            string pathBet = Path.Combine(directoryPath, ImageNames.FourthBoardCardSuit);
            imageWorker.SaveImage(cropFourthBoardCard, pathBet);
        }

        private void CropForThirdBoardCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropThirdBoardCard = imageWorker.CropImage(mainWindow, 25, 20, 373, 211);
            string pathBet = Path.Combine(directoryPath, ImageNames.ThirdBoardCardSuit);
            imageWorker.SaveImage(cropThirdBoardCard, pathBet);
        }

        private void CropForSecondBoardCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropSecondBoardCard = imageWorker.CropImage(mainWindow, 25, 20, 309, 211);
            string pathBet = Path.Combine(directoryPath, ImageNames.SecondBoardCardSuit);
            imageWorker.SaveImage(cropSecondBoardCard, pathBet);
        }

        private void CropForFirstBoardCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropFirstBoardCard = imageWorker.CropImage(mainWindow, 25, 20, 245, 211);
            string pathBet = Path.Combine(directoryPath, ImageNames.FirstBoardCardSuit);
            imageWorker.SaveImage(cropFirstBoardCard, pathBet);
        }

        private void CropForFifthBoardCardRank(Image mainWindow, string directoryPath)
        {
            Image cropFifthBoardCard = imageWorker.CropImage(mainWindow, 22, 18, 501, 188);
            string pathBet = Path.Combine(directoryPath, ImageNames.FifthBoardCardRank);
            imageWorker.SaveImage(cropFifthBoardCard, pathBet);
        }

        private void CropForFourthBoardCardRank(Image mainWindow, string directoryPath)
        {
            Image cropFourthBoardCard = imageWorker.CropImage(mainWindow, 22, 18, 437, 188);
            string pathBet = Path.Combine(directoryPath, ImageNames.FourthBoardCardRank);
            imageWorker.SaveImage(cropFourthBoardCard, pathBet);
        }

        private void CropForThirdBoardCardRank(Image mainWindow, string directoryPath)
        {
            Image cropThirdBoardCard = imageWorker.CropImage(mainWindow, 22, 18, 374, 188);
            string pathBet = Path.Combine(directoryPath, ImageNames.ThirdBoardCardRank);
            imageWorker.SaveImage(cropThirdBoardCard, pathBet);
        }

        private void CropForSecondBoardCardRank(Image mainWindow, string directoryPath)
        {
            Image cropSecondBoardCard = imageWorker.CropImage(mainWindow, 22, 18, 310, 188);
            string pathBet = Path.Combine(directoryPath, ImageNames.SecondBoardCardRank);
            imageWorker.SaveImage(cropSecondBoardCard, pathBet);
        }

        private void CropForFirstBoardCardRank(Image mainWindow, string directoryPath)
        {
            Image cropFirstBoardCard = imageWorker.CropImage(mainWindow, 22, 18, 246, 188);
            string pathBet = Path.Combine(directoryPath, ImageNames.FirstBoardCardRank);
            imageWorker.SaveImage(cropFirstBoardCard, pathBet);
        }

        private void CropHoleCards(string directoryPath)
        {
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFirstHoleCardRank(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFirstHoleCardSuit(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForSecondHoleCardRank(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForSecondHoleCardSuit(mainWindow, directoryPath);
            }
        }

        private void CropForFirstHoleCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropFirstHoleCard = imageWorker.CropImage(mainWindow, 25, 20, 703, 206);
            string pathBet = Path.Combine(directoryPath, ImageNames.FirstHoleCardSuit);
            imageWorker.SaveImage(cropFirstHoleCard, pathBet);
        }

        private void CropForSecondHoleCardSuit(Image mainWindow, string directoryPath)
        {
            Image cropFirstHoleCard = imageWorker.CropImage(mainWindow, 25, 20, 726, 206);
            string pathBet = Path.Combine(directoryPath, ImageNames.SecondHoleCardSuit);
            imageWorker.SaveImage(cropFirstHoleCard, pathBet);
        }

        private void CropForFirstHoleCardRank(Image mainWindow, string directoryPath)
        {
            Image cropFirstHoleCard = imageWorker.CropImage(mainWindow, 22, 18, 706, 183);
            string pathBet = Path.Combine(directoryPath, ImageNames.FirstHoleCardRank);
            imageWorker.SaveImage(cropFirstHoleCard, pathBet);
        }

        private void CropForSecondHoleCardRank(Image mainWindow, string directoryPath)
        {
            Image cropSecondHoleCard = imageWorker.CropImage(mainWindow, 22, 18, 728, 183);
            string pathBet = Path.Combine(directoryPath, ImageNames.SecondHoleCardRank);
            imageWorker.SaveImage(cropSecondHoleCard, pathBet);
        }

        private void CropPot(string directoryPath)
        {
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForPot(mainWindow, directoryPath);
            }
        }

        private void CropForPot(Image mainWindow, string directoryPath)
        {
            //pot
            Image cropBetImage = imageWorker.CropImage(mainWindow, 15, 40, 380, 122);
            string pathBet = Path.Combine(directoryPath, ImageNames.Pot);
            //imageWorker.SaveImage(cropBetImage, pathBet);

            Bitmap grayscale = imageWorker.Grayscale(new Bitmap(cropBetImage));
            imageWorker.SetBackgroundToWhite(grayscale);
            grayscale = imageWorker.ResizeBitmap(grayscale, 160, 60);
            imageWorker.SaveImage(grayscale, pathBet);
        }

        private void CropButtons(string directoryPath)
        {
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForCheckActionButton(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForFoldActionButton(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForBetActionButton(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForRaiseActionButton(mainWindow, directoryPath);
            }

            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForCallActionButton(mainWindow, directoryPath);
            }
            using (Image mainWindow = Image.FromFile(Path.Combine(directoryPath, ImageNames.TableWindow)))
            {
                CropForCallActionButtonChips(mainWindow, directoryPath);
            }
        }

        private void CropForCallActionButtonChips(Image mainWindow, string directoryPath)
        {
            //call
            Image cropCallImage = imageWorker.CropImage(mainWindow, 22, 100, 558, 510);
            string pathCall = Path.Combine(directoryPath, ImageNames.CallButtonChips);
            //imageWorker.SaveImage(cropCallImage, pathCall);

            Bitmap grayscale = imageWorker.Grayscale(new Bitmap(cropCallImage));
            grayscale = imageWorker.ResizeBitmap(grayscale, 200, 44);
            imageWorker.SetBackgroundToWhite(grayscale);
            imageWorker.SaveImage(grayscale, pathCall);
        }

        private void CropForBetActionButton(Image mainWindow, string directoryPath)
        {
            //bet
            Image cropBetImage = imageWorker.CropImage(mainWindow, 40, 55, 710, 495);
            string pathBet = Path.Combine(directoryPath, ImageNames.BetButton);
            imageWorker.SaveImage(cropBetImage, pathBet);
        }

        private void CropForRaiseActionButton(Image mainWindow, string directoryPath)
        {
            //bet
            Image cropRaiseImage = imageWorker.CropImage(mainWindow, 38, 67, 698, 495);
            string pathRaise = Path.Combine(directoryPath, ImageNames.RaiseButton);
            //imageWorker.SaveImage(cropRaiseImage, pathRaise);

            Bitmap grayscale = imageWorker.Grayscale(new Bitmap(cropRaiseImage));
            grayscale = imageWorker.ResizeBitmap(grayscale, 201, 114);
            imageWorker.SaveImage(grayscale, pathRaise);
        }

        private void CropForFoldActionButton(Image mainWindow, string directoryPath)
        {
            //fold
            Image cropFoldImage = imageWorker.CropImage(mainWindow, 20, 55, 455, 500);
            string pathFold = Path.Combine(directoryPath, ImageNames.FoldButton);
            imageWorker.SaveImage(cropFoldImage, pathFold);
        }

        private void CropForCheckActionButton(Image mainWindow, string directoryPath)
        {
            //check
            Image cropCheckImage = imageWorker.CropImage(mainWindow, 20, 55, 580, 500);
            string pathCheck = Path.Combine(directoryPath, ImageNames.CheckButton);
            imageWorker.SaveImage(cropCheckImage, pathCheck);
        }

        private void CropForCallActionButton(Image mainWindow, string directoryPath)
        {
            //call
            Image cropCallImage = imageWorker.CropImage(mainWindow, 40, 55, 580, 495);
            string pathCall = Path.Combine(directoryPath, ImageNames.CallButton);
            imageWorker.SaveImage(cropCallImage, pathCall);
        }
    }
}
